package School.Work.Text;
interface Shape1{
    public static final double PI=3.14159;
    public abstract double Area();
    public abstract double Perimeter();
}
class circle implements Shape1 {
    double r;
    public circle(double r){
        this.r=r;
    }
    public double Area(){
        return PI*r*r;
    }
    public double Perimeter(){
        return 2*PI*r;
    }
}
class square implements Shape1 {
    double x;
    public square(double x){
        this.x=x;
    }
    public double Area(){
        return x*x;
    }
    public double Perimeter(){
        return 4*x;
    }
}
public class TestDemo22 {
    public static void main(String[] args) {
        Shape1[] s=new Shape1[4];//定义一个接口数组
        s[0]=new circle(4.5);
        s[1]=new circle(4.2);
        s[2]=new square(4);
        s[3]=new square(3.5);
        double Total_Area=0;
        double Total_Perimeter=0;
        for(int i=0;i<s.length;i++){
            Total_Area+=s[i].Area();
        }
        System.out.println("总面积是："+Total_Area);
        for(int i=0;i<s.length;i++){
            Total_Area+=s[i].Perimeter();
        }
        System.out.println("总面积是："+Total_Perimeter);
    }
}
